<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input
        type="text"
        placeholder="enter the name you search"
        v-model="iptValue"
      />
      <button @click="axiosUser">Search</button>
    </div>
  </section>
</template>

<script>
import axios from "axios";
export default {
  name: "Header",
  props: ["getUserData"],
  data() {
    return {
      iptValue: "",
    };
  },
  methods: {
    async axiosUser() {
      //在请求前
      this.getUserData({ isInit: false, isSearch: true });
      //进行axios请求
      const data = await axios.get(
        `https://api.github.com/search/users?q=${this.iptValue}`
      );
      //在请求到数据后
      this.getUserData({ isInit: false, isSearch: false, userList:data.data.items });
    },
  },
};
</script>

<style></style>
